/*
 * RegMask.hpp create 2009-11-20
 * 	by ws
 */
#ifndef REGMASK_HPP
#define REGMASK_HPP
#include<vector>
#include"common.hpp"
class RegMask
{
	static const int Num_Cluster = 4;
	static const int Num_AGU = 3;
	static const int Reg_Num_Per_Cluster = 64;
	static const int Reg_Num_Per_AGU = 32;
	//four cluster, so have 2 * 4 cluster + 3 AGU + other special register = 12
	static const int mask_lenth = 12;
	unsigned int* mask;
	static void _union_add(RegMask & x, const RegMask & y);
public:
	int get_allowed_addr_reg(enum Core c);
	int get_allowed_data_reg(enum Core c);
	std::vector<int> get_allowed_simd_reg();
	RegMask();
	// a = a | b
	RegMask & operator |= (const RegMask & regs);

	void add_reg(TargetInfo::PhysicalRegister reg);
	void sub_reg(TargetInfo::PhysicalRegister reg);
	bool test_reg(TargetInfo::PhysicalRegister reg);//check the reg is within the mask 

	friend bool operator & (RegMask &x, RegMask &y);
	friend bool operator | (RegMask &x, RegMask &y);
	virtual ~RegMask();
};
extern bool operator &(RegMask& x, RegMask& y);
extern bool operator |(RegMask& x, RegMask& y);
#endif
